﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers; 
namespace WPFExcelReport
{
    public partial class TDKD02
    { 
        public TDKD02()
        {

            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VKDSTAMM();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            dwData = TBMain.NewRow();
            dwData["KDMANDANT"] = app.Mandant;
            SResult = TMV.QKD999(dwData);
            MergeData(SResult, false);
            base.QueryCommand(sender, e);
        }
        private void KD0Command(object sender, RoutedEventArgs e)
        {
            dwData = TBMain.NewRow();
            TMV.SetUpNewRow(ref dwData);
            dwData["KDSTAKZ"] = "A";
            dwData["KDKUNDNA"] =app.company.PadRight(8);
            dwData["KDNAME1"] = app.company.PadRight(40);
            dwData["KDKUNDNR"] = "00000000";
            dwData["KDKREDLIM1"] = 999999999;
            TMV.Insert(dwData);
            vwMaster.View.MoveCurrentToFirst();
        }
        public void ResetSeq(object sender, RoutedEventArgs e)
        { 
            // 重置客户流水号为1，KD03,KD05,KD14
            VSDDAT.SD22.RESETSEQ("0022", "  ", "KUNDNR", 1);
            dwData = TBMain.NewRow();
            dwData["KDMANDANT"] = app.Mandant;
            TMV.DKD00(dwData);
            dwData =TMV.VKDR. TBMain.NewRow();
            dwData["KDAMANDANT"] = app.Mandant;
            TMV.VKDR.DKUNDADR00(dwData);

            dwData = TMV.KDS.TBMain.NewRow();
            dwData["KDSMANDANT"] = app.Mandant; 
            TMV.KDS.DKDA00(dwData);

        } 
    }
}
